{extend name="common@base" /}
{block name="content"}
<link href="//cdn.bootcss.com/jquery-datetimepicker/2.5.4/jquery.datetimepicker.min.css" rel="stylesheet">
<style>
  .form-control {
    width: 200px;
  }
</style>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <form action="" method="post" class="form" id="form">
        <div class="box box-primary">
          <div class="box-header with-border">
            <div class="box-title">设定考试时间</div>
          </div>
          <div class="box-body">
            <div class="form-group">
              <label for="">考试时长(管理员已设定)<input type="text" id="exam_duration" class="form-control"
                                               value="{$row.exam_duration}分" disabled></label>
            </div>
            <div class="form-group">
              <label for="">开始时间<input type="text" name="form[start_time]" class="form-control bs-datetime"
                                       value="{$row.start_time}"></label>
            </div>
            <div class="form-group">
              <label for="">结束时间(自动计算)<input type="text" id="end_time" class="form-control"
                                             value="{$row.end_time}" disabled></label>
            </div>
          </div>
        </div>
        <div class="box box-deafult">
          <div class="box-footer">
            <button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
            <a href="javascript:history.back()" class="btn btn-default">返回</a>
          </div>
        </div>

      </form>
    </div>
  </div>
</section>
{/block}
{block name="page_script"}
<script>
  require(["jq-datetimepicker"], function (e) {
    var dateTimeInput = $(".bs-datetime");
    var examDuration = $("#exam_duration").val();
    var endTimeObj = $("#end_time");
    //datepicker
    $.datetimepicker.setLocale('zh');
    dateTimeInput.datetimepicker({
      step: 15,
      format: 'Y-m-d H:i:s',
      minTime: '8:00',
      maxTime: '19:15',
      onSelectTime: function (ct) {
        var timestamp = ct.valueOf();
        var timestamp4, endTime;
        timestamp += parseInt(examDuration) * 60 * 1000;
        timestamp4 = new Date(timestamp);
        endTime = timestamp4.toLocaleDateString().replace(/\//g, "-") + " " + timestamp4.toTimeString().substr(0, 8);
        endTimeObj.val(endTime);
      },
    });

    function getdate(date) {
      var now = date,
        y = now.getFullYear(),
        m = ("0" + (now.getMonth() + 1)).slice(-2),
        d = ("0" + now.getDate()).slice(-2);
      return y + "-" + m + "-" + d + " " + now.toTimeString().substr(0, 8);
    }
  });

  require(["layer_config", "ajaxForm"], function (layer) {

  });

</script>
{/block}





